package dal

import (
	"context"
	"github.com/cloudwego/hertz/pkg/common/hlog"
	"mall_admin_api/biz/model"
)

func (c *AdministratorDAO) Login(ctx context.Context, account string, password string) (*model.Administrator, error) {
	info, err := Administrator.WithContext(ctx).Where(Administrator.Account.Value(account), Administrator.Password.Value(password)).First()
	if err != nil {
		hlog.CtxErrorf(ctx, "get administrator info failed, %s", err.Error())
		return nil, err
	}
	return info, nil
}
